package com.maochd.platform.util;

import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StreamUtils;

import java.nio.charset.StandardCharsets;

/**
 * 模板工具类
 */
@UtilityClass
public class TemplateUtils {

    /**
     * 从classpath读取模板文件
     *
     * @param templatePath 模板路径
     * @return 模板内容
     */
    @SneakyThrows
    public static String loadTemplate(String templatePath) {
        ClassPathResource resource = new ClassPathResource(templatePath);
        return StreamUtils.copyToString(resource.getInputStream(), StandardCharsets.UTF_8);
    }
} 